package com.jd.controller;

import java.util.ArrayList;
import java.util.Date;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.jd.entity.Feedback;
import com.jd.entity.NameEntity;
import com.jd.entity.RulesEntity;
import com.jd.service.NameSrevice;
import com.jd.service.RulesService;
import com.jd.util.IdUtil;
import com.sun.org.apache.xpath.internal.operations.Bool;
/**
 * @author masicheng 
 * 时间 : 2020年12月16日 上午11:11:06 
 * 注释 :游戏/游戏门票
 */
@Controller
@RequestMapping("/nameController")
public class NameController {

	@Autowired
	private NameSrevice nameService;
	@Autowired
	private RulesService rulesService;
	
	@RequestMapping("getNameList")
	@ResponseBody
	public ArrayList<NameEntity> getNameList(HttpServletRequest request) {
		String name = request.getParameter("name");
		ArrayList<NameEntity> nameList = nameService.getNameList(name);
		return nameList;
	}
	//游戏字典
	@RequestMapping("getGameList")
	@ResponseBody
	public ArrayList<Map<String,String>> getGameList(HttpServletRequest request) {
		String pid = request.getParameter("pid");
		ArrayList<Map<String,String>> nameList = nameService.getGameList(pid);
		return nameList;
	}
	//游戏大区
	@RequestMapping("getAreaList")
	@ResponseBody
	public ArrayList<Map<String,String>> getAreaList(HttpServletRequest request) {
		ArrayList<Map<String,String>> nameList = nameService.getAreaList("region");
		return nameList;
	}
	//反馈类型
	@RequestMapping("getFedTypeList")
	@ResponseBody
	public ArrayList<Map<String,String>> getFedTypeList(HttpServletRequest request) {
		ArrayList<Map<String,String>> nameList = nameService.getAreaList("fklx");
		return nameList;
	}
	@RequestMapping("saveFeedback")
	@ResponseBody
	public Boolean saveFeedback(HttpServletRequest request) {
		String userId = request.getSession().getAttribute("userId").toString();
		String fedpic = request.getParameter("fedpic");
		String content = request.getParameter("content");
		String fedTypeCode = request.getParameter("fedTypeCode");
		Feedback feedback = new Feedback();
		feedback.setId(IdUtil.getIdByUUId());
		feedback.setUserId(userId);
		feedback.setFeedbackType(fedTypeCode);
		feedback.setContent(content);
		feedback.setPic(fedpic);
		feedback.setCreateBy(userId);
		feedback.setCreateTime(new Date());
		feedback.setRemark1("0");
		Boolean i = nameService.saveFeedback(feedback);
		return i; 
	}
	@RequestMapping("getRules")
	@ResponseBody
	public RulesEntity getRules(HttpServletRequest request) {
		RulesEntity rules = rulesService.getRules();
		return rules; 
	}

	@RequestMapping("getById")
	@ResponseBody
	public NameEntity getById(HttpServletRequest request) {
		String id = request.getParameter("id");
		NameEntity name = nameService.getNameById(id);
		return name;
	}
	
}
